package com.micro.user.controller;

import com.alibaba.nacos.api.model.v2.Result;
import com.micro.model.Order;
import com.micro.model.User;
import com.micro.user.client.OrderServiceClient;
import com.micro.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/users")
public class UserController {
    @Autowired
    private IUserService userService;


    @GetMapping("/{id}")
    public Result<User> getUserById(@PathVariable Long id) {
        return Result.success(userService.getUserById(id));
    }

    @GetMapping("/orders/{id}")
    public Result<Order> getOrderByUserId(@PathVariable Long id) {
        System.out.println("-------333-----");
        return Result.success(userService.getOrderById(id));
    }

}
